var model = require('../models/decorate.server.model');
var utilsModel =require('../models/menu.server.model');

module.exports = {
	getPower:function(req , res , next){
		var params = req.query || req.param;
		var userObj = req.session.user;
		utilsModel.getPower({roleId:userObj.user.ROLE_ID,menuId:params.menuId},function(result){
			res.send(result);
		});
	},
	getLevel2Menu:function(req , res , next){
		var params = req.query || req.param;
		var userObj = req.session.user;
		utilsModel.getMenu({roleId:userObj.user.ROLE_ID,place:params.menuId},function(result){
			res.send(result);
		});
	},
	getDecorateAll:function(req , res , next){
		var params = req.query || req.param;
		var userObj = req.session.user;
		model.getDecorateAll(params,function(result){
			var resObject = {code:0,result:result,role:userObj.role};
			model.getRedisArr().getRedisData(resObject,function(object){
				res.send(object);
			});
		});
	},
	addDecorate:function(req , res , next){
		var param = req.body;
		model.addDecorate(param,function(result){
			res.send(result);
		});
	},
	uploadDecorate:function(req , res , next){
		var param = req.body;
		model.uploadDecorate(param,function(result){
			res.send(result);
		});
	},
	removeDecorate:function(req , res, next){
		var param = req.body;
		model.removeDecorate(param,function(result){
			res.send(result);
		});
	}
};